-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[pkg/stanza] Fix collector stops reading new file after copytruncate rotation #43758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…rotation Signed-off-by: Paulo Dias <[email protected]>
Signed-off-by: Paulo Dias <[email protected]>
…ector-contrib into fix/43693 Signed-off-by: Paulo Dias <[email protected]>
andrzej-stencel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm marking this as "Request changes", because I want to be sure we understand the consequences before merging this.
In principle, the fingerprint is the identifier of a file. The biggest issue I see here is that this seems to dismiss this principle in some cases.
I'll examine this pull request and your comments @paulojmdias on the corresponding issue in more detail. Thank you for digging into this! 🙏
|
Sure @andrzej-stencel! Please let me know of you need something. Thanks for your review 🙏 |
andrzej-stencel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change has the following consequence: Removing anything (e.g. the last line) from the end of a file that is being read by the File Log receiver would cause the file to be read in its entirety again, as it would be seen as a new file by the receiver. For one, this change of behavior would be a big breaking change, and for another I'm not convinced that this is the expected behavior. The fingerprint of the file stays the same, so it's the same file. We should not ingest the same file twice.
…-contrib into fix/43693 Signed-off-by: Paulo Dias <[email protected]>
Signed-off-by: Paulo Dias <[email protected]>
|
I've implemented the configurable solution for handling copytruncate rotation as suggested by @andrzej-stencel here. I added a new The truncation detection logic appears in three separate code paths in I added comprehensive tests for all three modes and updated the @atoulme I'm also proposing being a CODEOWNER with you in the |
Description
When the log lines are written exactly with the first
1000bytes equal, if acopytruncatehappens, is there a possibility of stopping reading the file. This was discovered using theotlpjsonfilereceiver and doing thecopytruncateoption on multiple services.This PR resets the offsets if the current offset is higher than the file size, which usually happens when a
copytruncateoperation occurs.Link to tracking issue
Fixes #43693
Testing
Added tests to simulate writing the same lines more than 1000 bytes multiple times, and validate
copytruncateoffsets reset.